package net.ibizsys.eclipse.studio.data;

import net.ibizsys.eclipse.studio.i18n.I18n;

import com.alibaba.fastjson.JSONObject;

/**
 * 解决方案
 * 
 * @author <a href='http://www.weibo.com/xjtoo' target='_blank'>Enmaai</a>
 */
public class IBizSolution extends IBizData
{
	private JSONObject data;
	private String slnid;
	private String logicname;
	private String centername;

	public IBizSolution()
	{
	}

	public IBizSolution(JSONObject json)
	{
		init(json);
	}

	@Override
	public void init(JSONObject json)
	{
		this.data = json;
		this.slnid = json.getString("psdevslnid");
		this.logicname = json.getString("logicname");
		this.centername = json.getString("psdevcentername");
	}

	public JSONObject getData()
	{
		return data;
	}

	public String getSlnid()
	{
		return slnid;
	}

	public String getLogicname()
	{
		if (this.logicname == null || this.logicname.trim().length() == 0)
		{
			return I18n.Unknown;
		}
		return logicname;
	}

	public String getCentername()
	{
		if (this.centername == null || this.centername.trim().length() == 0)
		{
			return I18n.Unknown;
		}
		return centername;
	}

	public Object getValue(String key)
	{
		if (data.containsKey(key))
		{
			return data.get(key);
		}
		return null;
	}

	@Override
	public String getIcon()
	{
		return "icons/solution15.png";
	}

	@Override
	public String getText()
	{
		return String.format("%1$s<%2$s>", getLogicname(), getCentername());
	}
}
